package springboot.study.project.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: WebConfig
 * @Description: 拦截器配置
 * @Author: liu-hao
 * @Date: 2021-04-01 15:55
 * @Version: 1.0
 **/
@Configuration
//@EnableWebMvc //会使得你的静态资源以及exclude的全部失效！！！！
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    SesstionInterceptor sesstionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(sesstionInterceptor).addPathPatterns("/**").excludePathPatterns("/", "/login", "/user/login", "/error", "/js/**", "/css/**", "/images/**", "/layui/**", "/bootstrap/**"); //要排除路径;
    }
}